class ColumnAttr:
    def __init__(self, name, attr):
        attrs = attr.split(',')
        self.server_enable = 'c' not in attrs
        self.client_enable = 's' not in attrs
        self._key = None

        for attr in attrs:
            # 这是一个主键
            if attr.startswith('k'):
                self.key = attr[1:] and int(attr[1:]) or 1

        self.name = name

    @property
    def server_enable(self):
        return self._export_server
    
    @server_enable.setter
    def server_enable(self, value: bool):
        self._export_server = value

    @property
    def client_enable(self):
        return self._export_client

    @client_enable.setter
    def client_enable(self, value: bool):
        self._export_client = value

    @property
    def key(self):
        return self._key

    @key.setter
    def key(self, value: int):
        self._key = value

    def need_export(self, target: str):
        if target == "server":
            return self.server_enable
        elif target == "client":
            return self.client_enable

        return False

    def __str__(self):
        return f"ColumnAttr(name={self.name}, key={self.key}, export_server={self.server_enable}, export_client={self.client_enable})"